<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;

/**
 * h会议安排
 */
class Message extends Api
{

    protected $noNeedLogin = [''];
    // 无需鉴权的接口,*表示全部
    protected $noNeedRight = ['*'];


    /**
     *  user_id` varchar(255) DEFAULT NULL COMMENT '用户id',
     * `user_name` varchar(255) DEFAULT NULL COMMENT '用户名称',
     * `user_avatar` varchar(255) DEFAULT NULL COMMENT '头像',
     * `text` text COMMENT '信息',
     * `addtime` bigint(11) DEFAULT NULL COMMENT '创建时间',
     */
    public function submit()
    {

        $user=$this->auth->getUser();

        $data=[
            'user_id'=>$user['id'],
            'user_name'=>$user['nickname'],
            'user_avatar'=>$user['avatar'],
            'text'=>$this->request->request('desc'),
            'status'=>0,
            'addtime'=>time(),
        ];

        Db::name('message')
            ->data($data)
            ->insert();

        $this->success('提交成功,请等待审核');

    }

    public function getall(){

        $lists=Db::name('message')
            ->where('status',1)
            ->select();

        $this->success('获取成功',$lists);





    }

}